package com.itheima02.day06test;

import java.time.Duration;
import java.time.LocalDateTime;
import java.util.Scanner;

/**
 * @author 刘全
 * @date 2021/7/22
 */
//3. 键盘录入一个年份，判断这个年份是平年还是闰年（提示，闰年2月有29天，平年2月只有28天）
public class Test3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        //键盘录入一个年份
        System.out.println("请输入一个年份:");
        int year = sc.nextInt();
        LocalDateTime localDate1 = LocalDateTime.of(year,2,1,0,0,0);
        LocalDateTime localDate2 = LocalDateTime.of(year,3,1,0,0,0);
        Duration duration = Duration.between(localDate1, localDate2);
        //判断这个年份是平年还是闰年
        if (duration.toSeconds() == 3600 * 24 * 28) {
            System.out.println(year + "是平年");
        } else {
            System.out.println(year+"是闰年");
        }
    }
}
